﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHCfg = NHibernate.Cfg;

namespace InnovTech.Persistence
{
    public class DefaultSessionFactoryBuilder<TDatabaseInfo> : SessionFactoryBuilderBase<TDatabaseInfo>
        where TDatabaseInfo : INHDatabaseInfo
    {

        public DefaultSessionFactoryBuilder(TDatabaseInfo dbInfo)
            :base(dbInfo)
        {
        }

        protected override NHibernate.Cfg.Configuration GetConfiguration(TDatabaseInfo dbInfo)
        {
            NHCfg.Configuration config = new NHCfg.Configuration();
            config.AddProperties(dbInfo.GetConfigurationProperties());
            config.Properties.Add(NHCfg.Environment.ConnectionString, dbInfo.GetConnectionString());
            dbInfo.GetMappingAction<NHCfg.Configuration>()(config);
            return config;
        }
    }
}
